package com.cssy.xxkj.basic.dao.impl;


import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicPersonnelDAO;
import com.cssy.xxkj.basic.entity.BasicPersonnelDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-28
 */
public class BasicPersonnelDAOImpl extends SqlMapClientDaoSupport implements BasicPersonnelDAO {

    /**
     * 插入数据
     * @param basicPersonnelDO
     * @return 插入数据的主键
     */
    public String insertBasicPersonnelDO(BasicPersonnelDO basicPersonnelDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicPersonnel.insert", basicPersonnelDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicPersonnelDO
     * @return 查出的记录数
     */
    public Integer countBasicPersonnelDOByExample(BasicPersonnelDO basicPersonnelDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicPersonnel.countByDOExample", basicPersonnelDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicPersonnelDO
     * @return 受影响的行数
     */
    public Integer updateBasicPersonnelDO(BasicPersonnelDO basicPersonnelDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicPersonnel.update", basicPersonnelDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicPersonnelDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicPersonnelDO> findListByExample(BasicPersonnelDO basicPersonnelDO) throws DataAccessException {
        List<BasicPersonnelDO> list = getSqlMapClientTemplate().queryForList("BasicPersonnel.findListByDO", basicPersonnelDO);
        return list;
    }

    /**
     * 根据主键获取basicPersonnelDO
     * @param id
     * @return basicPersonnelDO
     */
    public BasicPersonnelDO findBasicPersonnelDOByPrimaryKey(String id) throws DataAccessException {
        BasicPersonnelDO basicPersonnelDO = (BasicPersonnelDO) getSqlMapClientTemplate().queryForObject("BasicPersonnel.findByPrimaryKey", id);
        return basicPersonnelDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicPersonnelDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicPersonnel.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicPersonnelDO> find(SearchConditions scs)
			throws DataAccessException {
		  List<BasicPersonnelDO> list=getSqlMapClientTemplate().queryForList("BasicPersonnel_ex.find",scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		 Integer rows=(Integer)getSqlMapClientTemplate().queryForObject("BasicPersonnel_ex.count",scs);
		return rows;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		   Integer rows=(Integer)getSqlMapClientTemplate().queryForObject("BasicPersonnel_ex.deleteBizRemoved",id); 
		return rows;
	}

}